package hackerrank.algorithms.warmup;

import java.util.*;

/**
 * Created by Tzachi on 16/10/2014.
 * <p>
 * The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the monsoon,
 * when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.
 * Now, a new Utopian tree sapling is planted at the onset of the monsoon. Its height is 1 meter.
 * Can you find the height of the tree after N growth cycles?
 */
public class UtopianTree {

    public static int calcHeight(int period) {
        // is even
        if (period % 2 == 0) {
            return (int) Math.pow(2, (period / 2 + 1)) - 1;
        } else {
            return (int) (2 * (Math.pow(2, ((period - 1) / 2 + 1))-1));
        }
    }

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner in = new Scanner(System.in);
        int numberOfTestCases; //
        numberOfTestCases = in.nextInt();
        List<Integer> periods = new LinkedList<Integer>();
        for (int i = 0; i < numberOfTestCases; i++) {
            periods.add(in.nextInt());
        }
        for (Integer period : periods) {
            System.out.println(calcHeight(period));
        }
    }
}
